package dao.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "student", catalog = "makeiteasy")
public class Student implements java.io.Serializable {

	// Fields
	private static final long serialVersionUID = 1L;
	private Integer stuId;
	private Classes classes;
	private String stuEmail;
	private String stuPassword;
	private String stuName;
	private Set<Score> scores = new HashSet<Score>(0);

	// Constructors

	/** default constructor */
	public Student() {
	}

	/** minimal constructor */
	public Student(String stuEmail, String stuPassword) {
		this.stuEmail = stuEmail;
		this.stuPassword = stuPassword;
	}

	/** full constructor */
	public Student(Classes classes, String stuEmail, String stuPassword,
			String stuName, Set<Score> scores) {
		this.classes = classes;
		this.stuEmail = stuEmail;
		this.stuPassword = stuPassword;
		this.stuName = stuName;
		this.scores = scores;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "stuId", unique = true, nullable = false)
	public Integer getStuId() {
		return this.stuId;
	}

	public void setStuId(Integer stuId) {
		this.stuId = stuId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "classId")
	public Classes getClasses() {
		return this.classes;
	}

	public void setClasses(Classes classes) {
		this.classes = classes;
	}

	@Column(name = "stuEmail", nullable = false, length = 64)
	public String getStuEmail() {
		return this.stuEmail;
	}

	public void setStuEmail(String stuEmail) {
		this.stuEmail = stuEmail;
	}

	@Column(name = "stuPassword", nullable = false, length = 16)
	public String getStuPassword() {
		return this.stuPassword;
	}

	public void setStuPassword(String stuPassword) {
		this.stuPassword = stuPassword;
	}

	@Column(name = "stuName", length = 64)
	public String getStuName() {
		return this.stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "student")
	public Set<Score> getScores() {
		return this.scores;
	}

	public void setScores(Set<Score> scores) {
		this.scores = scores;
	}

}